package com.example.service.impl;


import com.example.dao.SubjectDao;
import com.example.entity.Subject;
import com.example.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubjectServiceImpl implements SubjectService {

    @Autowired
    private SubjectDao subjectDao;

    @Override
    public List<Subject> getPage(int currentPage, int pageSize) {
        currentPage=currentPage*pageSize-pageSize;
        return subjectDao.getPage(currentPage,pageSize);
    }

    @Override
    public int getTotalCount() {

        return subjectDao.getTotalCount();
    }

    @Override
    public Boolean add(Subject subject) {
        int i = subjectDao.add(subject);
        System.out.println("测试:");
        System.out.println(i);
        if (i>=1){
            return true;
        }
        return false;
    }

    @Override
    public Boolean deleteById(Integer id) {

        return subjectDao.deleteById(id);
    }

    @Override
    public Boolean update(Subject subject) {
        int i = subjectDao.update(subject);
        if (i>=1){
            return true;
        }
        return false;
    }
}
